package com.apkplug.imthemedemo;

import org.apkplug.Bundle.ApkplugTheme;
import org.apkplug.Bundle.RegThemeChengeListener;
import org.apkplug.Bundle.ThemeAgent;
import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceEvent;
import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;

import android.content.Context;

public class ThemeChengFactory {
	private ThemeAgent<ApkplugTheme> ta=null;
	private BundleContext mcontext;
	private static ThemeChengFactory _instance=null;
	public ThemeChengFactory(final BundleContext mcontext){
		this.mcontext=mcontext;
		ta=new ThemeAgent<ApkplugTheme>(mcontext,String.format("(&(objectclass=%s)(serviceName=mystyle))",ApkplugTheme.class.getCanonicalName()));
	}
	synchronized public static ThemeChengFactory getInstance(BundleContext mcontext){
    if(_instance==null){
    _instance=new ThemeChengFactory(mcontext);
    }
    return _instance;
    } 
	public ApkplugTheme getService() {
		return ta.getService();
	}
	public RegThemeChengeListener getRegThemeChengeListener() throws Exception {
		return ta.getRegThemeChengeListener();
	}
}
